﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace ZhimeiSoft.CharmManager.DOL
{
    public class DBEntityBase : ICloneable
    {
        /// <summary>
        /// 将实体类转化成XML形式
        /// <![CDATA[
        ///     <EntityName>
        ///         <Property Name="Property1" Value="Value1" /> 
        ///         <Property Name="Property2" Value="Value2" /> 
        ///         <Property Name="PropertyList" Value="List">
        ///             <Items>
        ///                 <PropertyItem Name="" Value="" />
        ///             </Items>
        ///         </Property>
        ///     </EntityName>
        /// ]]>
        /// </summary>
        /// <returns>实体类的XML形式</returns>
        public string toXml()
        {
            string strReturn = string.Empty;
            Type type = typeof(DBEntityBase);
            PropertyInfo[] infos = type.GetProperties(BindingFlags.Public);
            foreach (PropertyInfo info in infos)
            {
                
            }
            return strReturn;
        }

        /// <summary>
        /// 表名称
        /// </summary>
        /// <returns>返回表名称</returns>
        public virtual string GetTableName()
        {
            return "";
        }

        #region ICloneable 成员

        public object Clone()
        {
            return this.MemberwiseClone();
        }

        #endregion
        /// <summary>
        /// 根据传入的字符串在字符串数组中查找，然后返回结果
        /// </summary>
        /// <param name="aStr">查找的字符串</param>
        /// <param name="searchStr"></param>
        /// <param name="returnStr"></param>
        /// <returns></returns>
        protected static string GetStrReturnStr(string aStr, string[] searchStr, string[] returnStr)
        {
            string sReturnStr = string.Empty;
            bool bfind = false;
            int index = 0;
            foreach (string str in searchStr)
            {
                if (aStr.ToUpper().Equals(str.ToUpper()))
                {
                    bfind = true;
                    break;
                }
                index++;
            }
            if (bfind)
            {
                return returnStr[index];
            }
            else
            {
                return string.Empty;
            }
        }
    }

}
